package com.example.demo9consumer.controller;

import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

/**
 * @author Created by yawn on 2017-11-01 15:47
 */
@RestController
public class ConsumerController {

    @Resource
    private RestTemplate restTemplate;

//    @GetMapping(value = "/consumer/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
    @GetMapping("/consumer/{id}")
    public Object getMessage(@PathVariable long id) {
        Object object = restTemplate.getForObject("http://service-provider/car/" + id, Object.class);
        return object;
    }
}
